package travlefate.story.activity;

import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.widget.TextView;

import me.imid.swipebacklayout.lib.SwipeBackLayout;
import travlefate.story.R;
import travlefate.story.adapter.StoryLookAdapter;
import travlefate.story.base.BaseSwipeActivity;
import travlefate.story.bean.ResultStory;

/**
 * @author keven
 * @data 15/12/23 上午10:34
 * @package travlefate.story.activity
 * 点击大图展示页面
 */

public class StoryLookActivity extends BaseSwipeActivity {

    private TextView mBarName;
    private Toolbar mToolBar;
    private ViewPager mLookPager;
    private ResultStory story;
    private StoryLookAdapter mLookAdapter;
    private int check;
    private TextView mPicCount;

    @Override
    protected void initDatas() {
        mBarName.setText(R.string.bar_look);
        story = (ResultStory) getIntent().getSerializableExtra("story");
        check = getIntent().getIntExtra("check", 0);
        mLookAdapter = new StoryLookAdapter(this, story);
        mLookPager.setAdapter(mLookAdapter);
        mLookPager.setCurrentItem(check);
        mPicCount.setText((check+1) + "/" + story.getPics().size());

    }

    @Override
    protected void initClick() {
        mLookPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                mPicCount.setText((position+1) + "/" + story.getPics().size());
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
    }

    @Override
    protected void initViews() {
        mBarName = (TextView) findViewById(R.id.bar_name);
        mToolBar = (Toolbar) findViewById(R.id.toolbar);
        mLookPager = (ViewPager) findViewById(R.id.story_look_pager);
        mPicCount = (TextView) findViewById(R.id.pic_count);
        SwipeBackLayout swipeBackLayout = getSwipeBackLayout();
        swipeBackLayout.setEdgeSize(20);
    }

    @Override
    protected void initLayout() {
        setContentView(R.layout.activity_story_look);
    }
}
